package org.shiwen.week3.answer;

import java.util.Scanner;

public class GuessNum {
    public static void main(String[] args) {
        int random  = (int)(Math.random()*100);
        int guess;
        int count = 0;
        Scanner sc = new Scanner(System.in);
        while(true){
            count++;
            System.out.println("请输入一个1-100的数字");
            guess = sc.nextInt();
            if(guess==random){
                System.out.println("你用"+count+"次猜对了结果");
                break;
            } else if (guess>random) {
                System.out.println("大了");
            } else{
                System.out.println("小了");
            }
        }
    }
}
